﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyServer.Common
{
    /// <summary>
    /// 数据转换器
    /// </summary>
    public abstract class DataConverter<T>
    {
        #region ==========方法==========

        /// <summary>
        /// 将对象转换为字节数组
        /// </summary>
        /// <param name="obj">要转换的对象</param>
        /// <returns>转换成的字节数组</returns>
        public abstract byte[] ConvertToByte(T obj);
        /// <summary>
        /// 将字节数组转换成对象
        /// </summary>
        /// <param name="data">要转换的字节数组</param>
        /// <returns>转换成的对象</returns>
        public abstract T ConvertToObject(byte[] data);

        #endregion
    }
}
